#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
int xbus_match(struct device *dev, struct device_driver *drv)
{
    printk("dev name:%s drv name :%s \n",dev_name(dev),drv->name);
    if (strncmp(dev_name(dev),drv->name,strlen(drv->name)) == 0)
    {
        printk("device and driver match\n");
        return 1;
    }
    printk("device and driver miss match\n");
    return 0;
}
int xbus_probe(struct device *dev)
{
    printk("xbus probe\n");
    return 0;
}
int xbus_remove(struct device *dev)
{
    printk("xbus_remove\n");
    return 0;
}
struct bus_type xbus = {
    .name = "xbus",
    .match = xbus_match,
    .probe = xbus_probe,
    .remove = xbus_remove,
};
EXPORT_SYMBOL(xbus);
int test_init(void)
{
    int ret = 0;
    ret = bus_register(&xbus);
    if (ret < 0)
    {
        printk("bus register is error\n");
        return -1;
    }
    printk("insmod xbus\n");
    return 0;
}
void test_exit(void)
{
    bus_unregister(&xbus);
    printk("bye\n");
}
MODULE_LICENSE("GPL");
module_init(test_init);
module_exit(test_exit);